/* eslint-disable */
const { Controller } = require('egg');

class FeedbackController extends Controller {
    //反馈列表
    async index() {
        const { ctx } = this
        // const type = ctx.query.type ? ctx.query.type : ''
        // const content = ctx.query.content ? ctx.query.content : ''
        // const user_id = ctx.query.user_id ? ctx.query.user_id : null
        const query = ctx.query ? ctx.query : ''
        const result = await ctx.service.feedback.findList(query)
        ctx.success(result, '查询反馈信息成功')
      }
    //创建反馈
    async create() {
        const { ctx } = this;
        const { id, content, type } = ctx.request.body;
        if (!user_id || !category || !content) {
            ctx.error('缺少必要的字段');
            return;
        }
        const result = await service.feedback.add({ id, content, type });
        ctx.success(result, '反馈数据成功');
    }
    //删除反馈
    async destroy() {
        const { ctx } = this;
        const id = ctx.params.is;
        const success = await ctx.service.feedback.remove(id);
        if (success) {
            ctx.success(null, '反馈删除成功');
        } else {
            ctx.error('反馈删除失败');
        }
    }
    // 更新反馈的状态
    async update() {
        const { ctx } = this;
        const {id,status} = ctx.params;
        const success = await ctx.service.feedback.modify(status, id);
        if (success) {
            ctx.success(null, '反馈状态更新成功');
        } else {
            ctx.error('反馈状态更新失败');
        }
    }

    // 查询单条反馈
    async show() {
        const { ctx } = this;
        const id = ctx.params.id;
        const result = await ctx.service.categories.findById(id);
        ctx.success(result, `查询id为${id}的反馈信息成功`);
    }

}

module.exports = FeedbackController;